<template>
  <div>
    <BasicModal
      width="80%"
      height="80%"
      v-bind="$attrs"
      @register="registerModal"
      title="二手商品详情"
      @ok="handleSubmit"
    >
      <Description @register="register" style="minheight: 500px" />
    </BasicModal>
  </div>
</template>
<script lang="ts">
  import { defineComponent, ref } from 'vue';
  import { BasicModal, useModalInner } from '/@/components/Modal';
  import { Description, useDescription } from '/@/components/Description/index';
  import { DetailsApi } from '/@/api/secondHandGoods/index';
  import { schema } from './data';

  export default defineComponent({
    name: 'SalesUserModal',
    components: {
      BasicModal,
      Description,
    },
    emits: ['success', 'register'],
    setup() {
      const mockData = ref({});
      const [registerModal, { closeModal }] = useModalInner(async (data) => {
        mockData.value = {};
        const Detail = await DetailsApi(data.record.id); //请求获取详情信息
        mockData.value = { ...Detail.data };
        console.log(mockData, '11111');
      });
      const [register] = useDescription({
        data: mockData,
        column: 2,
        schema: schema,
      });
      async function handleSubmit() {
        console.log('确认事件', mockData);

        closeModal();
      }
      return {
        registerModal,
        register,
        closeModal,
        handleSubmit,
        schema,
      };
    },
  });
</script>

function info(data: any, info: any) { throw new Error('Function not implemented.'); }
